package com.kingint.web.portal.base.controller;


import com.kingint.common.unitedresult.K;
import com.kingint.mbg.dto.GoodsReturn;
import com.kingint.web.portal.base.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goods")
@Api(value = "GoodsController", description = "前端消耗品和布草/易碎品相关表")
@CrossOrigin
public class GoodsController {

    @Resource
    private GoodsService goodsService;

    @ApiOperation(value = "获取消费品和布草/易耗品列表")
    @GetMapping("/getGoodsList")
    public Object getGoodsList(){
        List<GoodsReturn> allGoodsList = goodsService.getAllGoodsList();
        return K.ok().data(allGoodsList);
    }

    @ApiOperation(value = "获取消费品")
    @GetMapping("/getGoodsCustomerList")
    public Object getGoodsCustomerList(){
        List<GoodsReturn> allGoodsList = goodsService.getGoodsForType(1);
        return K.ok().data(allGoodsList);
    }

    @ApiOperation(value = "获取布草")
    @GetMapping("/getGoodsLinenList")
    public Object getGoodsLinenrList(){
        List<GoodsReturn> allGoodsList = goodsService.getGoodsForType(2);
        return K.ok().data(allGoodsList);
    }

    @ApiOperation(value = "获取易耗品")
    @GetMapping("/getGoodsFragileList")
    public Object getGoodsFragileList(){
        List<GoodsReturn> allGoodsList = goodsService.getGoodsForType(3);
        return K.ok().data(allGoodsList);
    }
}
